import { defineConfig } from 'vite';
import { builtinModules } from 'node:module';

export default defineConfig({
  build: {
    outDir: '.vite/build/preload',
    lib: {
      entry: 'src/preload/preload.js',  // 更新路径 
      formats: ['cjs'],
      fileName: () => 'preload.js'  // 输出文件名同步修改 
    },
    rollupOptions: {
      external: [
        'electron',
        ...builtinModules,
        ...builtinModules.map(m  => `node:${m}`)
      ]
    },
    emptyOutDir: false // 避免重复清空目录 
  }
});